﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebApplication1.Servidor1;

namespace WebApplication1
{
    public partial class CrearEmpresa : System.Web.UI.Page
    {
        Service1 servidor;
        string pais;

        protected void Page_Load(object sender, EventArgs e)
        {
            servidor = (Service1)Session["Server"];
            if (!Page.IsPostBack)
            {
                if (Session["Server"] != null)
                {
                    List<string> listOfNames = servidor.Consultar(2).ToList();
                    DropDownList1.DataSource = listOfNames;
                    DropDownList1.DataBind();
                }
            }
        }

        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            DropDownList DropDownList1 = (DropDownList)sender;
            pais = DropDownList1.SelectedValue.ToString();
        }

        protected void Button1_Click1(object sender, EventArgs e)
        {
            pais = DropDownList1.SelectedItem.Text;
            if ((TextBox1.Text != "") && (TextBox2.Text != "") && (TextBox3.Text != ""))
            {
                servidor.Crear_Empresa(TextBox1.Text, TextBox2.Text, TextBox3.Text, pais);
                Response.Redirect("Login.aspx");
            }
        }
    }
}